package re.kitri.common.DBConnect;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DBConnManager {

	final static String className = "oracle.jdbc.driver.OracleDriver";
	String url = "jdbc:oracle:thin:@127.0.0.1:1521:XE";
	String user = "TOTO";
	String password = "0000";
	
	Connection conn = null;
	PreparedStatement pstmt = null;
	ResultSet rs = null;

	public Connection connDB(){
		try {
			Class.forName(className);
		} catch(ClassNotFoundException e) {
			e.printStackTrace();
		}
		
		try {
			conn = DriverManager.getConnection(url, user, password);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return conn;
	}
	public void closeDB(Connection conn,PreparedStatement pstmt,ResultSet rs){
		try {
			if(rs != null ) rs.close();
			if(pstmt != null ) pstmt.close();
			if(conn != null ) conn.close();
		} catch(SQLException e) {
			e.printStackTrace();
		}
	}
	public void closeDB(Connection conn,PreparedStatement pstmt){
		try {
			if(pstmt != null ) pstmt.close();
			if(conn != null ) conn.close();
		} catch(SQLException e) {
			e.printStackTrace();
		}
	}
	

}
